package com.paw.hys.sa;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author lvzihai
 * @date 2022/9/20
 **/
@Slf4j
@Component
public class FallbackAlertService {



  public void alert (Class klass,Throwable throwable ){
    String klassName = klass.getName();
    String sdkName = "";
    Class anInterface = null;

    if(ArrayUtil.isNotEmpty(klass.getInterfaces())){
      anInterface = klass.getInterfaces()[0];
    }
    if(ArrayUtil.isNotEmpty(anInterface.getInterfaces())){
      anInterface = anInterface.getInterfaces()[0];
    }
    if(anInterface!=null){
      sdkName = anInterface.getName();
    }

    String callMethodName = Thread.currentThread().getStackTrace()[2].getMethodName();

    log.error("hystrix fallback className={} {}#{}",klassName,sdkName,callMethodName,throwable);


  }

}
